<?php

namespace app\admin\controller;

use app\admin\model\Admin;
use app\admin\model\Device;
use app\admin\model\Deviceorder;
use app\admin\model\User;
use app\common\controller\Backend;
use app\common\model\Attachment;
use fast\Date;
use think\Db;

/**
 * 控制台
 *
 * @icon   fa fa-dashboard
 * @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
 */
class Dashboard extends Backend
{

    /**
     * 查看
     */
    public function index()
    {

        $orderModel = new Deviceorder();

        $countOrder = $orderModel->whereTime('create_time','today')->where('status','not in',['paying','refund'])->count('id');
        $amountOrder = $orderModel->whereTime('create_time','today')->where('status','not in',['paying','refund'])->sum('price');

        $deviceModel = new Device();
        $countDevice = $deviceModel->count('id');
        $offlineDevice = $deviceModel->where('online_status',0)->count('id');

        $this->view->assign("countOrder",$countOrder);
        $this->view->assign("amountOrder",$amountOrder);
        $this->view->assign("countDevice",$countDevice);
        $this->view->assign("offlineDevice",$offlineDevice);

        return $this->view->fetch();
    }

}
